﻿using YunxSoft.AfterSchoolClazz.Models;
using NPOI.SS.UserModel;
using NPOI.Util;
using NPOI.XSSF.UserModel;
using System.IO;

namespace YunxSoft.AfterSchoolClazz.Services;

public class ExcelReader
{
    public List<string> GetSheetNames(string filePath)
    {
        var sheetNames = new List<string>();

        // 读取文件流
        using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
        {
            // 使用 XSSFWorkbook 处理 XLSX 文件
            XSSFWorkbook workbook = new XSSFWorkbook(fs);

            // 获取工作簿中所有的 sheet
            for (int i = 0; i < workbook.NumberOfSheets; i++)
            {
                sheetNames.Add(workbook.GetSheetName(i));
            }
        }

        return sheetNames;
    }

}
